<?php
session_start();
require '../nette/Nette/loader.php';
require '../db.php';
require '../localization/lang.php';
require '../core/core.sanitizer.php';
require '../core/core.security.php';
require '../core/core.time.php';
require '../core/core.jobs.php';
$login=new core_security;
if ($login->checklogin()=="OK") {

if ($_SESSION['role']==3){
$time=new core_time;

$time->time=$_POST['value'];
//echo $time->verify_time_format_wodate();
if ($time->verify_time_format_wodate()=="") {
$job=new core_job;
$job->id=$_POST['id'];

$job->from=$time->totimestampdef($_SESSION['date2'],$_POST['value']);
$job->edit_validate();
$job->to=$job->from + $job->duration;
$job->edit_validate();
$job->edit();
} else {
	echo $time->verify_time_format_wodate();
	}

//$job->edit();	
//echo $_POST['value'];
	} else {



$time=new core_time;
/*
if ($_POST['action']=="to") {

echo $time->computetime($_POST['from'],"00:00",$_POST['duration'],"to");
	}


if ($_POST['action']=="duration") {
$time=new core_time;
echo $time->computetime($_POST['from'],$_POST['to'],"00:00","duration");
	}
*/	





$time->time=$_POST['value'];
if ($time->verify_time_format_wodate()=="") {
$job=new core_job;
$job->id=$_POST['id'];
$job->from=$time->totimestampdef($_SESSION['date2'],$_POST['value']);
$job->edit_validate();
$job->duration=$job->to - $job->from;

$job->edit();	

	} else {
	//echo "lol".$time->verify_time_format_wodate();
	}
echo $_POST['value'];
}
}
